/*=============================================================================
**                                  
**                      Proprietary - Copyright (C) 2013
**-----------------------------------------------------------------------------
** Supported MCUs      : <PIC16F887 / MCU independent>
** Supported Compilers : <MPLABX IDE / compiler independent>
**-----------------------------------------------------------------------------
** File name         : IF_IO.h
**
** Module name       : IF_IO
**
**
** Summary: __________________________
**
**= History ===================================================================
** 1.00 03/04/2013 Cuong Chu
** - Creation
=============================================================================*/

#ifndef IF_IO_H
#define IF_IO_H
/*****************************************************************************/
/* INCLUSIONS                                                                */
/*****************************************************************************/
#include "Std_Types.h"
/*****************************************************************************/
/* SWITCH COMPILER                                                           */
/*****************************************************************************/
/* other compiler */
#define MPLABX_IDE                      STD_OFF
#define IF_8BIT_CLIENT
#define AC_CONTROLLER_BLK
/*****************************************************************************/
/* INCLUSIONS FILES OF MCU                                                   */
/*****************************************************************************/
#if(MPLABX_IDE == STD_ON)
#include <htc.h>
#include <PIC16F887.h>
#endif
/* other compiler */


/*****************************************************************************/
/* DEFINITION OF CONSTANTS && MACROS                                         */
/*****************************************************************************/
/* Compiler is MPLABX IDE */
#if(MPLABX_IDE == STD_ON)

#define IF_IO_INPUT      0x01
#define IF_IO_OUTPUT     0x00

#if defined(IF_8BIT_MASTER)
/* output control */
#define IF_IO_MASTER_START_INIT
#define IF_IO_MASTER_TRIGGER_INIT
#define IF_IO_MASTER_START(STD_LEVEL)
#define IF_IO_MASTER_TRIGGER(STD_LEVEL)

/* input control */
#define IF_IO_CLIENT_BUSY_INIT
#define IF_IO_CLIENT_ACK_INIT
#define IF_IO_CLIENT_BUSY_READ 0
#define IF_IO_CLIENT_ACK_READ 0

#define IF_IO_D0_PIN(LEVEL)
#define IF_IO_D1_PIN(LEVEL)
#define IF_IO_D2_PIN(LEVEL)
#define IF_IO_D3_PIN(LEVEL)

#define IF_IO_D0_INIT
#define IF_IO_D1_INIT
#define IF_IO_D2_INIT
#define IF_IO_D3_INIT

#else /* in client mode, gpio pin is input */
/* output control */
#define IF_IO_MASTER_START_INIT
#define IF_IO_MASTER_TRIGGER_INIT
#define IF_IO_MASTER_START_READ 0
#define IF_IO_MASTER_TRIGGER_READ 0

/* input control */
#define IF_IO_CLIENT_BUSY_INIT
#define IF_IO_CLIENT_ACK_INIT
#define IF_IO_CLIENT_BUSY(STD_LEVEL)
#define IF_IO_CLIENT_ACK(STD_LEVEL)

#define IF_IO_D0_PIN_READ 0
#define IF_IO_D1_PIN_READ 0
#define IF_IO_D2_PIN_READ 0
#define IF_IO_D3_PIN_READ 0

#define IF_IO_D0_INIT
#define IF_IO_D1_INIT
#define IF_IO_D2_INIT
#define IF_IO_D3_INIT

#endif /* End preprocessor IF_IO_MASTER */
#else /* other compiler */


#if defined(IF_8BIT_MASTER)

/* output control */
#define IF_IO_MASTER_START_INIT
#define IF_IO_MASTER_TRIGGER_INIT
#define IF_IO_MASTER_START(STD_LEVEL)
#define IF_IO_MASTER_TRIGGER(STD_LEVEL)

/* input control */
#define IF_IO_CLIENT_BUSY_INIT
#define IF_IO_CLIENT_ACK_INIT
#define IF_IO_CLIENT_BUSY_READ   0
#define IF_IO_CLIENT_ACK_READ    0

#define IF_IO_D0_PIN(LEVEL)   
#define IF_IO_D1_PIN(LEVEL)    
#define IF_IO_D2_PIN(LEVEL)   
#define IF_IO_D3_PIN(LEVEL)   

#define IF_IO_D0_INIT
#define IF_IO_D1_INIT
#define IF_IO_D2_INIT
#define IF_IO_D3_INIT

#else /* in client mode, gpio pin is input */
/* output control */
#define IF_IO_MASTER_START_INIT
#define IF_IO_MASTER_TRIGGER_INIT
#define IF_IO_MASTER_START_READ     0
#define IF_IO_MASTER_TRIGGER_READ   0

/* input control */
#define IF_IO_CLIENT_BUSY_INIT
#define IF_IO_CLIENT_ACK_INIT
#define IF_IO_CLIENT_BUSY(STD_LEVEL)
#define IF_IO_CLIENT_ACK(STD_LEVEL)

#define IF_IO_D0_PIN_READ          0
#define IF_IO_D1_PIN_READ          0
#define IF_IO_D2_PIN_READ          0
#define IF_IO_D3_PIN_READ          0

#define IF_IO_D0_INIT
#define IF_IO_D1_INIT
#define IF_IO_D2_INIT
#define IF_IO_D3_INIT

#endif /* End preprocessor IF_IO_MASTER */

#endif /* End preprocessor IF_IO_MASTER */

#if defined (AC_CONTROLLER_BLK)
/* define output control trigger */
#define IF_IO_TRIGGER_1_INIT
#define IF_IO_TRIGGER_1(STD_LEVEL)
#define IF_IO_TRIGGER_2_INIT
#define IF_IO_TRIGGER_2(STD_LEVEL)
#define IF_IO_TRIGGER_3_INIT
#define IF_IO_TRIGGER_3(STD_LEVEL)
#define IF_IO_TRIGGER_4_INIT
#define IF_IO_TRIGGER_4(STD_LEVEL)
#define IF_IO_TRIGGER_5_INIT
#define IF_IO_TRIGGER_5(STD_LEVEL)
#define IF_IO_TRIGGER_6_INIT
#define IF_IO_TRIGGER_6(STD_LEVEL)
#define IF_IO_TRIGGER_7_INIT
#define IF_IO_TRIGGER_7(STD_LEVEL)
#define IF_IO_TRIGGER_8_INIT
#define IF_IO_TRIGGER_8(STD_LEVEL)
/* define output control dimmer */
#define IF_IO_DIMMER_1_INIT
#define IF_IO_DIMMER_1(STD_LEVEL)
#define IF_IO_DIMMER_2_INIT
#define IF_IO_DIMMER_2(STD_LEVEL)
#define IF_IO_DIMMER_3_INIT
#define IF_IO_DIMMER_3(STD_LEVEL)
#define IF_IO_DIMMER_4_INIT
#define IF_IO_DIMMER_4(STD_LEVEL)
#endif

#endif /* IF_IO_H */

